--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 79ba89373aee0f2cdea3ed53d7ef3438dc68a9d2
Parents : 0573af2
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-12-09T17:58:56+01:00
Added message markup rendering option to preferences
Changes
5 files changed, 29 insertions(+), 2 deletions(-)
Diff
diff --git a/sbapp/main.py b/sbapp/main.py
index 24810146..91520078 100644
--- a/sbapp/main.py
+++ b/sbapp/main.py
@@ -3043,6 +3043,10 @@ class SidebandApp(MDApp):
self.sideband.save_configuration()
self.sideband.setstate("wants.viewupdate.conversations", True)
+ def save_trusted_markup_only(sender=None, event=None):
+ self.sideband.config["trusted_markup_only"] = self.settings_screen.ids.settings_trusted_markup_only.active
+ self.sideband.save_configuration()
+
def save_advanced_stats(sender=None, event=None):
self.sideband.config["advanced_stats"] = self.settings_screen.ids.settings_advanced_statistics.active
self.sideband.save_configuration()
@@ -3215,6 +3219,9 @@ class SidebandApp(MDApp):
self.settings_screen.ids.settings_lxmf_ignore_unknown.active = self.sideband.config["lxmf_ignore_unknown"]
self.settings_screen.ids.settings_lxmf_ignore_unknown.bind(active=save_lxmf_ignore_unknown)
+ self.settings_screen.ids.settings_trusted_markup_only.active = self.sideband.config["trusted_markup_only"]
+ self.settings_screen.ids.settings_trusted_markup_only.bind(active=save_trusted_markup_only)
+
self.settings_screen.ids.settings_ignore_invalid_stamps.active = self.sideband.config["lxmf_ignore_invalid_stamps"]
self.settings_screen.ids.settings_ignore_invalid_stamps.bind(active=save_lxmf_ignore_invalid_stamps)
diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py
index 028a73d4..b5841a82 100644
--- a/sbapp/sideband/core.py
+++ b/sbapp/sideband/core.py
@@ -410,6 +410,7 @@ class SidebandCore():
self.config["print_command"] = "lp"
self.config["eink_mode"] = False
self.config["lxm_limit_1mb"] = True
+ self.config["trusted_markup_only"] = False
# Connectivity
self.config["connect_transport"] = False
@@ -550,6 +551,8 @@ class SidebandCore():
self.config["lxm_limit_1mb"] = True
if not "hq_ptt" in self.config:
self.config["hq_ptt"] = False
+ if not "trusted_markup_only" in self.config:
+ self.config["trusted_markup_only"] = False
if not "input_language" in self.config:
self.config["input_language"] = None
diff --git a/sbapp/ui/conversations.py b/sbapp/ui/conversations.py
index d6241009..cc58db14 100644
--- a/sbapp/ui/conversations.py
+++ b/sbapp/ui/conversations.py
@@ -133,6 +133,7 @@ class Conversations():
unread = conv["unread"]
last_activity = conv["last_activity"]
trusted = conv["trust"] == 1
+ appearance_from_all = self.app.sideband.config["display_style_from_all"]
appearance = self.app.sideband.peer_appearance(context_dest, conv=conv)
is_object = self.app.sideband.is_object(context_dest, conv_data=conv)
da = self.app.sideband.DEFAULT_APPEARANCE
@@ -141,7 +142,7 @@ class Conversations():
conv_icon = self.trust_icon(conv)
fg = None; bg = None; ti_color = None
- if trusted and self.app.sideband.config["display_style_in_contact_list"] and appearance != None and appearance != da:
+ if (trusted or appearance_from_all) and self.app.sideband.config["display_style_in_contact_list"] and appearance != None and appearance != da:
fg = appearance[1] or da[1]; bg = appearance[2] or da[2]
ti_color = "Custom"
else:
diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py
index b90c3d6b..6ce6d6de 100644
--- a/sbapp/ui/layouts.py
+++ b/sbapp/ui/layouts.py
@@ -1624,6 +1624,22 @@ MDScreen:
disabled: False
active: False
+ MDBoxLayout:
+ orientation: "horizontal"
+ size_hint_y: None
+ padding: [0,0,dp(24),dp(0)]
+ height: dp(48)
+
+ MDLabel:
+ text: "Only render markup from trusted"
+ font_style: "H6"
+
+ MDSwitch:
+ id: settings_trusted_markup_only
+ pos_hint: {"center_y": 0.3}
+ disabled: False
+ active: False
+
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py
index 1b77f82a..65930b5e 100644
--- a/sbapp/ui/messages.py
+++ b/sbapp/ui/messages.py
@@ -378,7 +378,7 @@ class Messages():
for m in self.new_messages:
if not m["hash"] in self.added_item_hashes:
try:
- if not self.is_trusted:
+ if self.app.sideband.config["trusted_markup_only"] and not self.is_trusted:
message_input = str( escape_markup(m["content"].decode("utf-8")) ).encode("utf-8")
else:
message_input = m["content"]
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────